const os = require('os');
const ifaces = os.networkInterfaces();
let ip = '';
for (const dev in ifaces) {
  for (let i = 0; i < ifaces[dev].length; i++) {
    if (
      !ifaces[dev][i].internal &&
      ifaces[dev][i].family === 'IPv4' &&
      !ifaces[dev][i].address.includes('::') &&
      ifaces[dev][i].address !== '127.0.0.1'
    ) {
      ip = ifaces[dev][i].address;
      break;
    }
  }
}
module.exports = ip;
